<template>
  <div class="credit-msg-wrap">
    <Form
      :show-error="true"
      :show-error-message="false"
      class="form readonly"
      :scroll-to-error="true"
      :validate-first="true"
      input-align="right"
    >
      <template>
        <div class="block">
          <div class="title">
            <span><em>测试金额</em></span>
          </div>
          <Field
            class="big"
            name="test1"
            label="测试金额"
            type="number"
            readonly
          />
          <Field
            v-model="formItem.test2"
            name="test2"
            label="测试信息"
            readonly
          />

          <Field
            v-model="formItem.test3"
            name="test3"
            label="测试信息"
            readonly
          >
          </Field>
        </div>
        <div class="block">
          <div class="title">
            <span><em>测试信息</em></span>
          </div>

          <Field
            v-model="formItem.test4"
            name="test4"
            label="测试信息"
            readonly
          >
          </Field>

          <Field v-model="formItem.test5" name="test5" label="测试信息">
          </Field></div
      ></template>
      <Popup v-model="isSms" position="center">
        <div class="sms-wrap">
          <div class="title">
            短信验证码<Icon class="icon" name="cross" @click="isSms = false" />
          </div>
          <div class="tips">已发送至尾号&nbsp;{{ phone }}&nbsp;的手机</div>
          <PasswordInput
            :focused="keyboardShow"
            :value="smsCode"
            @focus="keyboardShow = true"
            :mask="false"
            class="pass"
          />
          <countdown
            apiName="index/smsCode"
            classBtn="countdown-btns"
            class="countdown"
            ref="countdown"
          />
        </div>
      </Popup>
      <div class="block">
        <div class="title">
          <span><em>测试信息</em></span>
        </div>

        <Field :value="'测试信息'" label="测试信息" readonly></Field>
        <Field
          v-model="formItem.testAccount"
          name="test5"
          label="测试信息"
          readonly
        ></Field>
        <Field name="testAccount" label="测试信息" readonly></Field>
      </div>

      <div class="btns">
        <Button
          round
          class="btn"
          type="info"
          @click="isShow = true"
          loading-text="加载中..."
          block
          >阅读协议</Button
        >
        <Button
          round
          class="btn"
          type="info"
          @click="isSms = true"
          loading-text="加载中..."
          block
          >倒计时</Button
        >
        <Button
          round
          class="btn"
          type="info"
          @click="$router.push({ name: 'cropper' })"
          loading-text="加载中..."
          block
          >上传图片</Button
        >
        <Footer />
      </div>
    </Form>
    <agreement
      v-model="isShow"
      :list="['demo', 'demo1']"
      :interval="5"
      @done="done"
      @close="close"
    />
  </div>
</template>
<script>
import { Form, Field, Button, Icon, Popup } from "vant";
import agreement from "../components/agreements";
import countdown from "_c/countdownVerification";
export default {
  data() {
    return {
      isShow: false,
      isSms: false,
      keyboardShow: false,
      smsCode: "",
      phone: "18888888888",
      formItem: {},
    };
  },
  props: {
    testAmount: {
      default: "0",
    },
    creditPeriod: {
      default: "",
    },
  },
  components: { Form, Field, Button, Icon, agreement, countdown, Popup },
  created() {},
  mounted() {},
  computed: {},
  methods: {
    getFormData() {
      this.$api("post", "index/test", {}).then((res) => {
        this.items = res.data;
      });
    },
    done(close) {
      close();
    },
    close() {},
    back() {
      this.$emit("close");
    },
  },
};
</script>
<style lang="scss" scoped>
.message-alert {
  margin-bottom: 24px;
}
.credit-msg-wrap {
  padding: 0 20px;
  box-sizing: border-box;
  padding-top: 80px;
  background-repeat: no-repeat;
  background-position: 0 0;
  background-image: linear-gradient(rgb(223, 223, 255), #fff);
  background-size: 100%;
  .block {
    margin-bottom: 24px;
  }
  .repayment {
    margin-top: 69px;
    text-align: center;
  }
  .btns {
    display: flex;
    flex-wrap: wrap;
    margin-top: auto;
    margin-left: 20px;
    margin-right: 20px;
    justify-content: center;
    &.justify {
      justify-content: space-between;
    }
    .n2,
    .sm {
      width: calc(50% - 0.5em);
      & + .n2 {
        margin-left: 20px;
      }
    }
    .n3 {
      width: calc(33% - 0.5em);
    }
    button {
      margin: 0;
      margin-bottom: 1em;
    }
  }
}
.agreement-wrap {
  margin: 0 30px;
  margin-top: 96px;
  ::v-deep(.van-checkbox__label) {
    line-height: 1.5;
  }
}
.form {
  height: calc(100vh - 38.667vw);
  display: flex;
  flex-direction: column;
}
.title {
  font-size: 24px;
  padding-bottom: 12px;
  padding-left: 12px;
}
.sms-wrap {
  background-color: #fff;
  padding: 30px;
  border-radius: 8px;
  .title {
    position: relative;
    text-align: center;
    font-weight: bold;
    border-bottom: 1px solid #ccc;
    padding-bottom: 12px;
    margin-bottom: 15px;
    .icon {
      position: absolute;
      right: 0;
    }
  }
}
.tips {
  font-size: 16px !important;
  color: #555;
}
.title {
  font-size: 16px !important;
  color: #555;
}
</style>
